//
//  TrackPictureView.m
//  student
//
//  Created by JCai on 2018/10/25.
//  Copyright © 2018 higer. All rights reserved.
//

#import "TrackPictureView.h"
#import "TrackImageView.h"
#import "TrackDrawingView.h"


@interface TrackPictureView ()

@property (nonatomic, strong) NSMutableArray *imageArray;
@property (nonatomic, strong) TrackDrawingView *drawingView;


@end


@implementation TrackPictureView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        _imageArray = [[NSMutableArray alloc] init];
        
        TrackDrawingView *drawingView = [[TrackDrawingView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(frame), CGRectGetHeight(frame))];
        self.drawingView = drawingView;
    }
    return self;
}

- (void)reloadPicture:(CGSize)viewSize
{
    [self.drawingView removeFromSuperview];
    
    CGRect tempFrame = CGRectMake(0, 0, 128, 128);
    for (NSInteger i=0; i<648; i++) {
        NSInteger x = i / 24;
        NSInteger y = i % 24;
        tempFrame.origin.x = x * 128;
        tempFrame.origin.y = y * 128;
        TrackImageView *imageView = [[TrackImageView alloc] initWithFrame:tempFrame];
        NSString *fileName = [NSString stringWithFormat:@"%@_%@", @(x), @(y)];
        [imageView reloadPicture:fileName];
        [self addSubview:imageView];
    }
    [self addSubview:self.drawingView];
}

#pragma mark ==========刷新数据==========
- (void)reloadDrawing:(NSArray *)paths
{
    [self.drawingView reloadDrawing:paths];
}

- (void)reloadLineLayer:(NSInteger)pathSelect
{
    [self.drawingView reloadLineLayer:pathSelect];
}
@end
